#ifndef __win_painter_h__
#define __win_painter_h__

#include "../core/paint.h"
#include "../base/common.h"
#include "../tool/scoped_ptr.h"
#include "windefine.h"
#include "winresource.h"
#include "winfactory.h"
#include "winimage.h"
#include "font_helper.h"

#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")

class WinPainterImpl : public FacePainterImpl
{
public:
    WinPainterImpl();
    ~WinPainterImpl();

public:
    virtual int SetClipRect( const core::rect &rect );

    virtual bool ClearClipRect( int clip );

    virtual void DrawRectangle
              (
                const core::rect &rect,
                core::dword style,
                core::color color,
                int alpha
               );

    virtual void FillRectangle
              (
                const core::rect &rect,
                core::color color,
                int alpha
               );

    virtual void DrawImage
              (
                const std::wstring &file,
                const core::rect &rect,
                int alpha
               );

    virtual void DrawGridImage
              (
                const std::wstring &file,
                const core::rect &rect,
                const core::rect &grid,
                int length,
                int index,
                int alpha
               );

    virtual void SetTextFont
              (
                const std::wstring &family,
                const core::unit &size,
                core::dword format
               );

    virtual void DrawString
              (
                const std::wstring &text,
                const core::rect &rect,
                core::color color,
                core::dword align,
                int alpha
               );

    virtual int GetCharacterPosition
              (
                const std::wstring &text,
                int &width
               );

private:
    ULONG_PTR gdi_token_;

    std::wstring font_family_;
    int          font_size_;
    DWORD        font_style_;

    static const int DEFAULT_FONT_SIZE   = 12;
    static const int DEFAULT_FONT_RATE   = 100;
    static const int MAX_ALPHA           = 255;
    static const int DEFAULT_BLACK_COLOR = RGB( 0x01, 0x01, 0x01 );

private:
    DISABLE_COPY_AND_ASSIGN(WinPainterImpl)
};


#endif